import { fileURLToPath, URL } from 'node:url'

import {defineConfig, loadEnv} from 'vite'
import vue from '@vitejs/plugin-vue'

let devEnv= "http://localhost:8081";
let demEnv= "http://www.red-coral.cn:8080";

export default defineConfig({
  base: '/messageplus',
  plugins: [
    vue(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  server: {
    proxy: {
      '/dev': {
        target: devEnv+"/messageplus",
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/dev/, '')
      },
      '/dem': {
        target: demEnv,
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/dem/, '')
      }
    }
  }
})
